package com.atguigu.gulimall.product.rpc;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gulimall.product.biz.CategoryBizSerivce;
import com.atguigu.gulimall.web.vo.CategoryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author nicc
 * @version 1.0
 * @className CategoryRpcController
 * @date 2022-10-03 12:48
 *
 *  内部之间进行调用的
 */
@RequestMapping("/api/inner/product")
@RestController
public class CategoryRpcController {

    @Autowired
    CategoryBizSerivce categoryBizSerivce;

    /**
     * 数据库查询所有分类，封装成一个嵌套的树形结构
     * @return
     */
    @GetMapping("/categorys/tree")
    public Result<List<CategoryVo>> getCategorys(){
        List<CategoryVo>  tree = categoryBizSerivce.getCategorysTree();
        return Result.ok(tree);
    }

}